bitkeeper revision 1.531 (3f9da0175ZA8nMoVtg9tCQeXL4osyw)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 27 Oct 2003 22:45:43 +0000 (22:45 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 27 Oct 2003 22:45:43 +0000 (22:45 +0000)
time.c, xen_log.c, xen_cpuperf.c:
  Add 'independent_wallclock' cmdline and sysctl options to xenolinux.

tools/misc/xen_cpuperf.c
tools/misc/xen_log.c
xenolinux-2.4.22-sparse/arch/xeno/kernel/time.c

index 293997b7559dfd149dd9e576609ac990d4d7156d..e023a648a79a61651c1606ae8d99571ec8af6124 100644 (file)
@@ -16,7 +16,6 @@
 #include <string.h>
 
 #include "p4perf.h"
-#include "hypervisor-ifs/dom0_ops.h"
 #include "dom0_defs.h"
 
 void dom0_wrmsr( int cpu_mask, int msr, unsigned int low, unsigned int high )
index ed7d570e1cc81f48b70888e5ca952a178fc1920b..012b934030c4171702dea7e393366f0085f71c55 100644 (file)
@@ -13,7 +13,6 @@
 #include <sys/wait.h>
 #include <string.h>
 
-#include "hypervisor-ifs/dom0_ops.h"
 #include "dom0_defs.h"
 #include "mem_defs.h"
 
index 65280df6ce33b901489d19689a2e003ab25efbde..5b31e7fcf546f543c4ee7159adbdd2493be6c2a0 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/irq.h>
+#include <linux/sysctl.h>
 
 spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
 extern rwlock_t xtime_lock;
@@ -103,6 +104,16 @@ static u64 processed_system_time;
     } while ( 0 )
 
 
+/* Does this guest OS track Xen time, or set its wall clock independently? */
+static int independent_wallclock = 0;
+static int __init __independent_wallclock(char *str)
+{
+    independent_wallclock = 1;
+    return 1;
+}
+__setup("independent_wallclock", __independent_wallclock);
+
+
 #ifdef CONFIG_XENO_PRIV
 /*
  * In order to set the CMOS clock precisely, set_rtc_mmss has to be
@@ -248,11 +259,9 @@ void do_gettimeofday(struct timeval *tv)
 
 void do_settimeofday(struct timeval *tv)
 {
-#ifdef CONFIG_XENO_PRIV
     struct timeval newtv;
-    dom0_op_t op;
     
-    if ( start_info.dom_id != 0 )
+    if ( !independent_wallclock && (start_info.dom_id != 0) )
         return;
     
     write_lock_irq(&xtime_lock);
@@ -283,17 +292,23 @@ void do_settimeofday(struct timeval *tv)
     time_maxerror = NTP_PHASE_LIMIT;
     time_esterror = NTP_PHASE_LIMIT;
 
-    last_rtc_update = last_xen_update = 0;
-
-    op.cmd = DOM0_SETTIME;
-    op.u.settime.secs        = newtv.tv_sec;
-    op.u.settime.usecs       = newtv.tv_usec;
-    op.u.settime.system_time = shadow_system_time;
-
-    write_unlock_irq(&xtime_lock);
-
-    HYPERVISOR_dom0_op(&op);
+#ifdef CONFIG_XENO_PRIV
+    if ( start_info.dom_id == 0 )
+    {
+        dom0_op_t op;
+        last_rtc_update = last_xen_update = 0;
+        op.cmd = DOM0_SETTIME;
+        op.u.settime.secs        = newtv.tv_sec;
+        op.u.settime.usecs       = newtv.tv_usec;
+        op.u.settime.system_time = shadow_system_time;
+        write_unlock_irq(&xtime_lock);
+        HYPERVISOR_dom0_op(&op);
+    }
+    else
 #endif
+    {
+        write_unlock_irq(&xtime_lock);
+    }
 }
 
 asmlinkage long sys_stime(int *tptr)
@@ -336,7 +351,7 @@ static inline void do_timer_interrupt(int irq, void *dev_id,
         processed_system_time += NS_PER_TICK;
     }
     
-    if ( (time_status & STA_UNSYNC) != 0 )
+    if ( !independent_wallclock && ((time_status & STA_UNSYNC) != 0) )
     {
         /* Adjust shadow timeval for jiffies that haven't updated xtime yet. */
         shadow_tv.tv_usec -= (jiffies - wall_jiffies) * (1000000/HZ);
@@ -439,3 +454,24 @@ void __init time_init(void)
 
     clear_bit(_EVENT_TIMER, &HYPERVISOR_shared_info->events);
 }
+
+
+/*
+ * /proc/sys/xeno: This really belongs in another file. It can stay here for
+ * now however.
+ */
+static ctl_table xeno_subtable[] = {
+    {1, "independent_wallclock", &independent_wallclock,
+     sizeof(independent_wallclock), 0644, NULL, proc_dointvec},
+    {0}
+};
+static ctl_table xeno_table[] = {
+    {123, "xeno", NULL, 0, 0555, xeno_subtable},
+    {0}
+};
+static int __init xeno_sysctl_init(void)
+{
+    (void)register_sysctl_table(xeno_table, 0);
+    return 0;
+}
+__initcall(xeno_sysctl_init);